package cn.zswltech.gruul.common.exception;

import lombok.Data;

/**
 * @author Jim
 * @version 1.0.0
 * @descripition:
 * @date 2024/3/15 10:06
 */
@Data
public class BaseException extends RuntimeException{

    public static final Integer ERROR_CODE = 600;

    private Integer errCode;
    private String errMsg;

    public BaseException(String errMsg){
        super(errMsg);
        this.errCode = ERROR_CODE;
        this.errMsg = errMsg;
    }

    public BaseException(Integer errCode,String errMsg){
        super(errMsg);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public BaseException(BaseErrorEnum baseErrorEnum){
        super(baseErrorEnum.getErrMsg());
        this.errCode = baseErrorEnum.getErrCode();
        this.errMsg = baseErrorEnum.getErrMsg();
    }

    public BaseException(Integer errCode,String errMsg,Object... args){
        super(String.format(errMsg, args));
        this.errCode = errCode;
        this.errMsg = String.format(errMsg, args);
    }

    public BaseException(BaseErrorEnum baseErrorEnum,Object... args){
        super(String.format(baseErrorEnum.getErrMsg(), args));
        this.errCode = baseErrorEnum.getErrCode();
        this.errMsg = String.format(baseErrorEnum.getErrMsg(), args);
    }

}
